#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>

//x类型[0.5字节],y数量[1.5字节],起始地址[2字节]
#define MODBUS_CONFIG_TABLE(x,y,z) ((uint32_t)(x << 28)|(uint32_t)(y << 16)|((uint32_t)z))

uint32_t vdata_modbus_config_list[] = {
    MODBUS_CONFIG_TABLE(1,0,128),
    MODBUS_CONFIG_TABLE(3,0,64),
    MODBUS_CONFIG_TABLE(3,64,41)
};

int main(void)
{
    for(int i = 0; i < (sizeof(vdata_modbus_config_list)/sizeof(uint32_t));i++){
        printf("vdata_modbus_config_list[%d] -> 0x%08X\r\n", i, vdata_modbus_config_list[i]);
        switch (vdata_modbus_config_list[i] >> 28) {
            case 0x01:
                printf("send [0x01][0x01][%X][%X]\r\n", (vdata_modbus_config_list[i] >> 16) & 0xFFF, vdata_modbus_config_list[i] & 0xFFFF);
                break;
            case 0x02:
                printf("send [0x01][0x02][%X][%X]\r\n", (vdata_modbus_config_list[i] >> 16) & 0xFFF, vdata_modbus_config_list[i] & 0xFFFF);
                break;
            case 0x03:
                printf("send [0x01][0x03][%X][%X]\r\n", (vdata_modbus_config_list[i] >> 16) & 0xFFF, vdata_modbus_config_list[i] & 0xFFFF);
                break;
            case 0x04:
                printf("send [0x01][0x04][%X][%X]\r\n", (vdata_modbus_config_list[i] >> 16) & 0xFFF, vdata_modbus_config_list[i] & 0xFFFF);
                break;
            default:
                break;
        }
    }
}
